package com.lang.aspect.exception;

import com.lang.exception.BaseException;
import com.lang.response.PlatformResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * creat by SimonLang
 * 2022/12/29 12:09
 */

@RestControllerAdvice
public class GlobalExceptionHandler {


    /**
     * 自定义异常处理
     * @param baseException 自定义异常类
     * @return
     */
    @ExceptionHandler(value = BaseException.class)
    public PlatformResult baseExceptionHandler(BaseException baseException){
        return PlatformResult.FAIL(baseException.getCode(),baseException.getMessage());
    }
}

